from web.template import CompiledTemplate, ForLoop, TemplateResult


# coding: utf-8
def index (comments,commcount,pages):
    __lineoffset__ = -4
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'<html>\n'])
    extend_([u'        <head>\n'])
    extend_([u'                <title>web.py guestbook on GAE</title>\n'])
    extend_([u'                <link rel="stylesheet" href="./static/base.css" media="all"/>\n'])
    extend_([u'                <!-- jQuery -->\n'])
    extend_([u'                <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>\n'])
    extend_([u'                <!-- markItUp! -->\n'])
    extend_([u'                <script type="text/javascript" src="/static/markitup/jquery.markitup.js"></script>\n'])
    extend_([u'                <!-- markItUp! toolbar settings -->\n'])
    extend_([u'                <script type="text/javascript" src="/static/markitup/sets/html/set.js"></script>\n'])
    extend_([u'                <!-- markItUp! skin -->\n'])
    extend_([u'                <link rel="stylesheet" type="text/css" href="/static/markitup/skins/markitup/style.css" />\n'])
    extend_([u'                <!--  markItUp! toolbar skin -->\n'])
    extend_([u'                <link rel="stylesheet" type="text/css" href="/static/markitup/sets/html/style.css" />\n'])
    extend_([u'        </head>\n'])
    extend_([u'        <body>\n'])
    extend_([u'                <script language="javascript">\n'])
    extend_([u'                \n'])
    extend_([u'                ', u'$', u'(document).ready(function()    {\n'])
    extend_([u'        ', u'$', u"('#markItUp').markItUp(mySettings);\n"])
    extend_([u'        ', u'$', u"('.add').click(function() {\n"])
    extend_([u'                ', u'$', u".markItUp( {   openWith:'<opening tag>',\n"])
    extend_([u"                                                closeWith:'<\\/closing tag>',\n"])
    extend_([u'                                                placeHolder:"New content"\n'])
    extend_([u'                                        }\n'])
    extend_([u'                                );\n'])
    extend_([u'                return false;\n'])
    extend_([u'        });\n'])
    extend_([u'        ', u'$', u"('.toggle').click(function() {\n"])
    extend_([u'                if (', u'$', u'("#markItUp.markItUpEditor").length === 1) {\n'])
    extend_([u'                        ', u'$', u'("#markItUp").markItUpRemove();\n'])
    extend_([u'                        ', u'$', u'("span", this).text("get markItUp! back");\n'])
    extend_([u'                } else {\n'])
    extend_([u'                        ', u'$', u"('#markItUp').markItUp(mySettings);\n"])
    extend_([u'                        ', u'$', u'("span", this).text("remove markItUp!");\n'])
    extend_([u'                }\n'])
    extend_([u'                return false;\n'])
    extend_([u'        });\n'])
    extend_([u'});\n'])
    extend_([u'                </script>\n'])
    extend_([u'                <form method="post" action="/guestbook/">\n'])
    extend_([u'                        <p>name:<input type="text" name="author" /><br />\n'])
    extend_([u'                                detail:<textarea id="markItUp" name="content" cols="60" rows="10"></textarea>\n'])
    extend_([u'                                <br/>\n'])
    extend_([u'                                <input type="submit" value="Comments" /></p>\n'])
    extend_([u'                </form>\n'])
    extend_([u'                <div align="left">\n'])
    extend_([u'                        total ', escape_(commcount, True), u':\n'])
    for page in loop.setup(range(1,pages+1)):
        extend_(['                        ', u'    <a href="/?page=', escape_(page, True), u'">', escape_(page, True), u'</a>\n'])
    extend_([u'                </div>\n'])
    extend_([u'                <ul>    \n'])
    if comments:
        extend_(['                ', u'    <div class="reply-doc"> \n'])
        for comment in loop.setup(comments):
            extend_(['                            ', u'    <div class="bg-img-green">\n'])
            extend_(['                            ', u'            [', escape_(comment.date.strftime("%Y-%m-%d %H:%M:%S"), True), u']      ', escape_(comment.author, True), u':\n'])
            extend_(['                            ', u'    </div>\n'])
            extend_(['                            ', u'    <p>\n'])
            extend_(['                            ', u'    ', escape_(comment.content, False), u'\n'])
            extend_(['                            ', u'    </p>\n'])
        extend_(['                ', u'    </div>  \n'])
    else:
        extend_(['                ', u'    <em>no data</em>\n'])
    extend_([u'        </body>\n'])
    extend_([u'\n'])
    extend_([u'</html>\n'])

    return self

index = CompiledTemplate(index, 'templates/index.html')
join_ = index._join; escape_ = index._escape

